<template>
  <div class="collapse" :class="{top: !isShow}">
    <div class="title" @click="isShow = !isShow">
      <p class="text">{{title}}
        <i class="icon el-icon-caret-bottom" :class="{top: isShow}"></i>
      </p>
    </div>
    <el-collapse-transition>
      <div class="content" v-show="isShow">
        <slot></slot>
      </div>
    </el-collapse-transition>
  </div>
</template>

<script>
export default {
  props: ['title'],
  data() {
    return {
      // 折叠还是展开
      isShow: true
    }
  }
}
</script>

<style lang="less" scoped>
  // 折叠面板
  .collapse {
    margin: 0px 5px 10px 5px;
    border: 1px solid #c0c0c0;
    &.top {
      border: 0px solid #c0c0c0;
      border-top: 1px solid #c0c0c0;
    }
    .title {
      margin-top: -17px;
      display: flex;
      align-items: center;
      height: 35px;
      padding: 0 45px;
      color: #1b1b1b;
      cursor: pointer;

      .text {
        font-size: 18px;
        color: #1b1b1b;
        background: #ffffff;
        padding: 0px 10px;
      }
      .icon {
        transition: transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
        &.top {
          transform: rotate(180deg);
        }
      }
    }
  }
</style>
